<template>
	<view>
		<view class="order">
			<u-tabs :list="list" :is-scroll="false" active-color="#FF7F00" inactive-color=" #666666" :bold="bold"
				:current="current" @change="change"></u-tabs>
			<!-- 全部 -->
			<view class="tabs_box" :class="{dis:current == 0}">
				<view class="order_box" v-for="(item,index) in lists" :key="index"
					@click="bindorderDetail(item.indentNumber,item.orderId)">
					<view class="order_success" v-if="item.indentState=='2'">
						<view class="order_name">待支付领取</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='3'">
						<view class="order_name flex align-center">
							待取货
							<text style="color: red;margin-left: 10rpx;" v-if="item.isOverTake == 1">
								(取货已超时)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='4'">
						<view class="order_name flex align-center">
							配送中
							<text style="color: red;margin-left: 10rpx;" v-if="item.isOverDelivery == 1">
								(配送已超时)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='5'">
						<view class="order_name flex align-center">
							已完成
							<text style="color: red;margin-left: 10rpx;"
								v-if="item.isOverDelivery == 1 || item.isOverTake == 1">
								(超时订单)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='6'">
						<view class="order_name flex align-center">
							已完成
							<text style="color: red;margin-left: 10rpx;"
								v-if="item.isOverDelivery == 1 || item.isOverTake == 1">
								(超时订单)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='7'">
						<view class="order_name flex align-center">
							已完成
							<text style="color: red;margin-left: 10rpx;"
								v-if="item.isOverDelivery == 1 || item.isOverTake == 1">
								(超时订单)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='10'">
						<view class="order_name">已取消</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='9'">
						<view class="order_name">已取消</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_city">
						<view class="city_type">
							<view class="type_name" v-if="item.indentType == 1">帮我送</view>
							<view class="type_name" v-if="item.indentType == 2">帮我取</view>
							<view class="type_name" v-if="item.indentType == 3">同城帮买</view>
							<view class="type_name" v-if="item.indentType == 4">同城服务</view>
							<view class="type_name" v-if="item.indentType == 5">同城外卖</view>
							<view class="city_text" v-if="item.itemType">{{item.itemType}}</view>
						</view>
						<view class="city_address" v-if="item.indentType == 1 || item.indentType == 2">
							<view class="fh_box">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 3">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 4">
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 5">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_btn">
						<view class="btn1" v-if="item.indentState=='3'" @click.stop="quxiao(item.indentNumber)">取消订单
						</view>
						<!-- <view class="btn1"  v-if="item.indentState=='6'">客户待确认</view> -->
						<view class="btn2" v-if="item.indentState=='3'" @click.stop="quhuo(item.indentId)">确认取货</view>
						<view class="btn2" v-if="item.indentState=='4'" @click.stop="onshow(item)">确认送达</view>
						<view class="btn2" v-if="item.indentState=='9'">已取消</view>
						<view class="btn2" v-if="item.indentState=='10'">已取消</view>
					</view>
				</view>
			</view>
			<!-- 待取货 -->
			<view class="tabs_box" :class="{dis:current == 1}">
				<view class="order_box" v-for="(item,index) in lists" :key="index"
					@click="bindorderDetail(item.indentNumber,item.orderId)">
					<view class="order_success" v-if="item.indentState=='2'">
						<view class="order_name">待支付领取</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='3'">
						<view class="order_name flex align-center">
							待取货
							<text style="color: red;margin-left: 10rpx;" v-if="item.isOverTake == 1">
								(取货已超时)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_city">
						<view class="city_type">
							<view class="type_name" v-if="item.indentType == 1">帮我送</view>
							<view class="type_name" v-if="item.indentType == 2">帮我取</view>
							<view class="type_name" v-if="item.indentType == 3">同城帮买</view>
							<view class="type_name" v-if="item.indentType == 4">同城服务</view>
							<view class="type_name" v-if="item.indentType == 5">同城外卖</view>
							<view class="city_text" v-if="item.itemType">{{item.itemType}}</view>
						</view>
						<view class="city_address" v-if="item.indentType == 1 || item.indentType == 2">
							<view class="fh_box">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 3">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 4">
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 5">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_btn">
						<view class="btn1" v-if="item.indentState=='3'" @click.stop="quxiao(item.indentNumber)">取消订单
						</view>
						<view class="btn2" v-if="item.indentState=='3'" @click.stop="quhuo(item.indentId)">确认取货</view>
					</view>
				</view>
			</view>
			<!-- 配送中 -->
			<view class="tabs_box" :class="{dis:current == 2}">
				<view class="order_box" v-for="(item,index) in lists" :key="index"
					@click="bindorderDetail(item.indentNumber,item.orderId)">
					<view class="order_success" v-if="item.indentState=='4'">
						<view class="order_name flex align-center">
							配送中
							<text style="color: red;margin-left: 10rpx;" v-if="item.isOverDelivery == 1">
								(配送已超时)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='5'">
						<view class="order_name">已完成</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='6'">
						<view class="order_name">已完成</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='7'">
						<view class="order_name">已完成</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_city">
						<view class="city_type">
							<view class="type_name" v-if="item.indentType == 1">帮我送</view>
							<view class="type_name" v-if="item.indentType == 2">帮我取</view>
							<view class="type_name" v-if="item.indentType == 3">同城帮买</view>
							<view class="type_name" v-if="item.indentType == 4">同城服务</view>
							<view class="type_name" v-if="item.indentType == 5">同城外卖</view>
							<view class="city_text" v-if="item.itemType">{{item.itemType}}</view>
						</view>
						<view class="city_address" v-if="item.indentType == 1 || item.indentType == 2">
							<view class="fh_box">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 3">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 4">
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 5">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_btn">
						<view class="btn1" v-if="item.indentState=='3'">取消订单</view>
						<!-- <view class="btn1" v-if="item.indentState=='6'">客户待确认</view> -->
						<view class="btn2" v-if="item.indentState=='3'" @click.stop="quhuo(item.indentId)">确认取货</view>
						<view class="btn2" v-if="item.indentState=='4'" @click.stop="onshow(item)">确认送达</view>
						<view class="btn2" v-if="item.indentState=='9'">已取消</view>
					</view>
				</view>
			</view>
			<!-- 已完成 -->
			<view class="tabs_box" :class="{dis:current == 3}">
				<view class="order_box" v-for="(item,index) in lists" :key="index"
					@click="bindorderDetail(item.indentNumber,item.orderId)">
					<!-- <view class="order_success" v-if="item.indentState=='4'">
						<view class="order_name">配送中</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view> -->
					<view class="order_success" v-if="item.indentState=='5'">
						<view class="order_name flex align-center">
							已完成
							<text style="color: red;margin-left: 10rpx;"
								v-if="item.isOverDelivery == 1 || item.isOverTake == 1">
								(超时订单)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='6'">
						<view class="order_name flex align-center">
							已完成
							<text style="color: red;margin-left: 10rpx;"
								v-if="item.isOverDelivery == 1 || item.isOverTake == 1">
								(超时订单)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<view class="order_success" v-if="item.indentState=='7'">
						<view class="order_name flex align-center">
							已完成
							<text style="color: red;margin-left: 10rpx;"
								v-if="item.isOverDelivery == 1 || item.isOverTake == 1">
								(超时订单)
							</text>
						</view>
						<view class="order_data">{{item.receivingTime}}</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_city">
						<view class="city_type">
							<view class="type_name" v-if="item.indentType == 1">帮我送</view>
							<view class="type_name" v-if="item.indentType == 2">帮我取</view>
							<view class="type_name" v-if="item.indentType == 3">同城帮买</view>
							<view class="type_name" v-if="item.indentType == 4">同城服务</view>
							<view class="type_name" v-if="item.indentType == 5">同城外卖</view>
							<view class="city_text" v-if="item.itemType">{{item.itemType}}</view>
						</view>
						<view class="city_address" v-if="item.indentType == 1 || item.indentType == 2">
							<view class="fh_box">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 3">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 4">
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
						<view class="city_address" v-if="item.indentType == 5">
							<view class="fh_box" v-if="item.buy_type == 1">
								<view class="fh_image">
									<image src="../../static/image/icon_f.png"></image>
								</view>
								<view class="box">
									<view class="fh_name">{{item.shopAddressDetail}}</view>
									<view class="fh_type">{{item.shopName}}
										<text>{{item.shopPhone}}</text>
									</view>
								</view>
							</view>
							<view class="sh_box">
								<view class="sh_image">
									<image src="../../static/image/icon_s.png"></image>
								</view>
								<view class="box">
									<view class="sh_name">{{item.userAddressDetail}}</view>
									<view class="sh_type">{{item.userName}}
										<text>{{item.userPhone}}</text>
									</view>
								</view>
							</view>
						</view>
					</view>
					<u-line color="#E6E6E6" />
					<view class="order_btn">
						<view class="btn1" v-if="item.indentState=='3'">取消订单</view>
						<!-- <view class="btn1" v-if="item.indentState=='6'">客户待确认</view> -->
						<view class="btn2" v-if="item.indentState=='3'" @click="quhuo(item.indentId)">确认取货</view>
						<view class="btn2" v-if="item.indentState=='4'" @click="onshow(item)">确认送达</view>
						<view class="btn2" v-if="item.indentState=='9'">已取消</view>
					</view>
				</view>
			</view>
			<empty v-if="lists.length == 0"></empty>
			<!-- 收货码弹框 -->
			<u-popup v-model="shows" mode="center" border-radius="18" :closeable="closeable" close-icon="close-circle"
				close-icon-size="45" width="580rpx" height="400rpx">
				<view class="receipt_code">
					<view class="code_title">填写收货码</view>
					<u-input v-model="shouhuoma" type="text" placeholder="请输入收货码" :border="true" />
					<view class="sure" @click="querenSh">确定</view>
				</view>
			</u-popup>
		</view>

	</view>
</template>

<script>
	import empty from '@/components/empty'
	export default {
		components: {
			empty
		},
		data() {
			return {
				shows: false,
				closeable: true,
				shouhuoma: '',
				list: [{
					name: '全部'
				}, {
					name: '待取货'
				}, {
					name: '配送中'
				}, {
					name: '已完成'
				}],
				current: 0,
				bold: false,
				page: 1,
				limit: 5,
				order: [],
				lists: [],
				totalCount: 0,
				longitude: '', //经度
				latitude: '', //纬度
				indentState: '', //订单状态
				indentNumber: '', //订单号
				arr: [],
				showModal111: true,
			}
		},
		onLoad() {

			var that = this
			uni.getLocation({
				type: 'wgs84',
				success: function(res) {
					console.log('当前位置的经度：' + res.longitude);
					console.log('当前位置的纬度：' + res.latitude);
					that.longitude = res.longitude
					that.latitude = res.latitude
					that.taskData()
				}
			});
		},
		onShow() {
			let zhuandan = this.$queue.getData('zhuandan');
			if (zhuandan) {
				this.$queue.remove('zhuandan');
				this.page = 1;
				this.taskData();
			}
			//订单即将过期通知 370
			this.$Request.getT('/app/common/type/370').then(res => {
				if (res.code === 0) {
					this.arr.push(res.data.value)
				}
			});
			// #ifdef MP-WEIXIN
			if (this.showModal111) {
				this.openMsg()
			}
			// #endif
		},
		methods: {
			openMsg() {
				console.log('订阅消息')
				var that = this
				uni.getSetting({
					withSubscriptions: true, //是否获取用户订阅消息的订阅状态，默认false不返回
					success(ret) {
						console.log(ret.subscriptionsSetting, '------------------')
						// if (ret.subscriptionsSetting.itemSettings && Object.keys(ret.subscriptionsSetting.itemSettings).length == 2) {
						if (ret.subscriptionsSetting.itemSettings) {
							uni.setStorageSync('sendMsg', true)
							uni.openSetting({ // 打开设置页 
								success(rea) {
									console.log(rea.authSetting)
								}
							});
						} else { // 用户没有点击“总是保持以上，不再询问”则每次都会调起订阅消息
							uni.setStorageSync('sendMsg', false)
							uni.showModal({
								title: '提示',
								content: '为了更好的体验,请绑定消息推送',
								confirmText: '确定',
								cancelText: '取消',
								success: function(res) {
									if (res.confirm) {
										wx.requestSubscribeMessage({
											tmplIds: that.arr,
											success(re) {
												var datas = JSON.stringify(re);
												if (datas.indexOf("accept") != -1) {
													console.log(re)
													// uni.setStorageSync('sendMsg', true)
												}
											},
											fail: (res) => {
												console.log(res)
											}
										})
										// uni.setStorageSync('sendMsg', true)

										that.showModal111 = false
									} else if (res.cancel) {
										console.log('取消')
										// uni.setStorageSync('sendMsg', false)
										that.showModal111 = true
									}
								}
							})
						}
					}
				})
			},
			change(index) {
				uni.showLoading({
					title: '加载中......',
					icon: 'none'
				})
				this.current = index;
				this.lists = []
				this.page = 1;
				if (index == 0) {
					this.indentState = ''
				}
				if (index == 1) {
					this.indentState = 3
				}
				if (index == 2) {
					this.indentState = 4
				}
				if (index == 3) {
					this.indentState = 6
				}
				if (index == 4) {
					this.indentState = 9
				}
				this.taskData()
			},
			// 订单获取
			taskData() {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
				uni.showLoading({
					title: '加载中......',
					icon: 'none'
				})
				this.$Request.getT('/app/tbindent/findRiderIndent', {
					page: this.page,
					limit: 10,
					indentState: this.indentState
				}).then(res => {
					uni.hideLoading()
					if (this.page == 1) {
						this.lists = res.data.list
					} else {
						this.lists = this.lists.concat(res.data.list)
					}
					for (var i in this.lists) {
						if (this.lists[i].distanceInitial > 1000) {
							this.lists[i].distanceInitials = (Number(this.lists[i].distanceInitial) / 100)
								.toFixed(2)
						}
						if (this.lists[i].distance > 1000) {
							this.lists[i].distances = (Number(this.lists[i].distance) / 100).toFixed(2)
						}
					}
					console.log('lists', this.lists)
					this.totalCount = res.data.totalCount
					uni.stopPullDownRefresh();
				});
			},
			// 订单详情
			bindorderDetail(indentNumber, orderId) {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
				console.log(indentNumber, orderId)
				uni.navigateTo({
					url: '/pages/index/orderdetail/orderdetail?id=' + indentNumber + '&orderId=' + orderId
				})
			},
			// 取消订单
			quxiao(indentNumber) {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
				let that = this
				console.log('indentNumber', indentNumber)
				uni.showModal({
					title: '取消订单将会被扣保证金',
					content: '',
					cancelText: '取消',
					confirmText: '确认'
				}).then(res => {
					that.$Request.postT('/app/tbindent/riderCancleIndent', {
						indentNumber: indentNumber
					}).then(res => {
						console.log(res)
						if (res.code == 0) {
							that.page = 1
							that.taskData()
							uni.showToast({
								title: '订单已取消',
								icon: "none"
							});

						} else {
							uni.showToast({
								title: res.msg,
								icon: "none"
							});
						}
					});
				}).catch(err => {})

			},
			quhuo(indentId) {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
				let that = this
				uni.showModal({
					title: '提示',
					content: '确认取到货吗',
					success: function(res) {
						if (res.confirm) {
							that.$Request.postJson('/app/tbindent/riderBuyGoods', {
								indentId: indentId,
								indentState: 4
							}).then(res => {
								if (res.code == 0) {
									that.page = 1
									that.taskData()
									uni.showToast({
										title: '确认取货成功',
										icon: "none"
									});
								} else {
									uni.showToast({
										title: res.msg,
										icon: "none"
									});
								}
							});
						}
					}
				})
			},
			onshow(e) {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
				this.indentNumber = e.indentNumber
				if (e.itemCodeFlag == 0) {
					this.shows = true

				} else {
					this.querenSh()
				}
			},
			querenSh() {
				// #ifdef MP-WEIXIN
				if (uni.getStorageSync('sendMsg')) {
					uni.requestSubscribeMessage({
						tmplIds: this.arr,
						success(re) {
							// console.log(re,'**********')
							var datas = JSON.stringify(re);
							if (datas.indexOf("accept") != -1) {
								console.log(re)
							}
						},
						fail: (res) => {
							console.log(res)
						}
					})
				}
				// #endif
				this.$Request.postT('/app/tbindent/riderDelivery', {
					indentNumber: this.indentNumber,
					itemCode: this.shouhuoma
				}).then(res => {
					console.log(res)
					if (res.code == 0) {
						this.page = 1;
						this.taskData()
						uni.showToast({
							title: '订单完成',
							icon: "none"
						});
						this.shows = false

					} else {
						uni.showToast({
							title: res.msg,
							icon: "none"
						});
					}
				});
			}
		},
		onReachBottom: function() {
			if (this.page < this.totalCount) {
				this.page += 1;
				this.taskData();
			}
		},
		onPullDownRefresh: function() {
			this.page = 1;
			this.taskData();
		},

	}
</script>

<style>
	body {
		background: #F5F5F5;
	}

	.tabs_box {
		display: none;
	}

	.dis {
		display: block;
		width: 100%;
	}

	.u-tab-item {
		font-size: 26upx !important;
		/* color: #666666 !important; */
	}

	.success_box {
		width: 100%;
	}

	.order_box {
		width: 90%;
		margin: 0 auto;
		/* height: 390rpx; */
		background: #FFFFFF;
		margin-top: 20rpx;
		border-radius: 16px;
		padding-bottom: 16rpx;
	}

	.order_success {
		width: 90%;
		margin: 0 auto;
		display: flex;
		height: 80upx;
	}

	.order_name {
		flex: 1;
		display: flex;
		justify-content: left;
		align-items: center;
		font-weight: bold;
		font-size: 26rpx;
		letter-spacing: 1upx;
	}

	.order_data {
		flex: 1;
		color: #999999;
		display: flex;
		justify-content: flex-end;
		align-items: center;
		font-size: 24rpx;
	}

	.city_type {
		width: 90%;
		margin: 0 auto;
		height: 60upx;
		line-height: 60upx;
		display: flex;
		justify-content: left;
		align-items: center;
	}

	.type_name {
		font-size: 27rpx;
	}

	.city_text {
		width: 70rpx;
		line-height: 36rpx;
		color: #49A5FF;
		background: #c4e2ff;
		text-align: center;
		font-size: 19rpx;
		margin-left: 20rpx;
	}

	.city_address {
		width: 85%;
		margin: 0 auto;
		margin-top: -10rpx;
	}

	/* 发货地址 */
	.fh_box {
		display: flex;
		/* height: 80upx; */
		margin-top: 20upx;
	}

	.fh_image {
		flex: 1;
	}

	.box {
		flex: 11;
	}

	.fh_name {
		font-size: 26rpx;
		font-weight: 600;
		letter-spacing: 2upx;
	}

	.fh_type {
		color: #999999;
		font-size: 22upx;
	}

	.fh_type text {
		margin-left: 20upx;
	}

	/* 送货地址 */
	.sh_box {
		display: flex;
		margin-bottom: 14upx;
		margin-top: 14rpx;
	}

	.sh_image {
		flex: 1;
	}

	.sh_name {
		font-size: 26rpx;
		font-weight: 600;
		letter-spacing: 2upx;
	}

	.sh_type {
		color: #999999;
		font-size: 22upx;
	}

	.sh_type text {
		margin-left: 20upx;
	}

	.fh_image image {
		width: 30upx;
		height: 30upx;
	}

	.sh_image image {
		width: 30upx;
		height: 30upx;
	}

	.order_btn {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		/* height: 80upx; */
		margin-top: 8upx;
	}

	.btn1 {
		width: 170upx;
		font-size: 22upx;
		line-height: 60upx;
		text-align: center;
		border: 1upx solid #9C9C9C;
		border-radius: 20upx;
		color: #9C9C9C;
		margin-right: 30upx;
	}

	.btn2 {
		width: 170upx;
		line-height: 60upx;
		color: white;
		background: #FF6A04;
		font-size: 22upx;
		text-align: center;
		margin-right: 30upx;
		border-radius: 20upx;
	}

	/* 收货码弹框 */
	.receipt_code {
		width: 90%;
		margin: 0 auto;
	}

	.code_title {
		width: 100%;
		line-height: 100rpx;
		font-size: 31rpx;
		font-weight: bold;
		text-align: center;
		letter-spacing: 2rpx;
		margin-top: 21rpx;
		margin-bottom: 25rpx;
	}

	.u-input--border {
		border: 1px solid #F2F2F2 !important;
		background: #F2F2F2 !important;
		color: #999999 !important;
		font-weight: 500 !important;
		letter-spacing: 2rpx !important;
	}

	.u-input__input {
		font-size: 30rpx;
		font-weight: bold;
		flex: 1;
		color: #999999 !important;
		min-height: 85rpx !important;
		margin-top: 7rpx;
	}

	.sure {
		width: 100%;
		height: 80rpx;
		background: #FF7F00;
		color: white;
		border-radius: 46rpx;
		text-align: center;
		line-height: 80rpx;
		margin-top: 30rpx;
		letter-spacing: 2rpx;
	}
</style>